<template>
  <el-row type="flex"
          justify="center">
    <el-col :xl="10"
            :lg="8"
            align="middle">
      <label style="font-size:25px"> 个人中心</label>
      <el-form :model="userForm"
               :rules="rules"
               ref="userForm"
               label-width="100px"
               class="demo-ruleForm">
        <el-form-item label="用户名"
                      prop="username"
                      style="width: 380px">
          <el-input v-model="userForm.username"></el-input>
        </el-form-item>
        <el-form-item label="密码"
                      prop="password"
                      style="width: 380px">
          <el-input v-model="userForm.password"></el-input>
        </el-form-item>
        <el-form-item label="确认密码"
                      prop="ispassword"
                      style="width: 380px">
          <el-input v-model="userForm.password"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"
                     @click="submitForm('userForm')">提交</el-button>
          <el-button @click="resetForm('userForm')">重置</el-button>
        </el-form-item>
      </el-form>
    </el-col>
  </el-row>
</template>
<script>
export default {
  name: 'UserCenter',
  components: {},
  props: {},
  data() {
    return {
      userForm: {
        username: null,
        password: null,
        captcha: null,
        capToken: null,
      },
      rules: {
        username: [
          { required: true, message: '用户名不能为空', trigger: 'change' },
        ],
        password: [
          { required: true, message: '密码不能为空', trigger: 'blur' },
        ],
      },
    }
  },
  created() {},
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (!valid) {
          return
        }
        this.$axios
          .post('/sts/editPass', {
            data: this.loginForm,
          })
          .then((res) => {
            this.$message.success('修改成功')
          })
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    },
  },
  watch: {},
  computed: {},
  mounted() {},
}
</script>
<style scoped>
.el-row {
  background-color: #fafafa;
  height: 100%;
  display: flex;
  align-items: center;
  text-align: center;
}
</style>